package ticket

import (
	"context"
	"go.uber.org/zap"
	"ticket_srv/config"
	"ticket_srv/internal/model/dao"
	__ "ticket_srv/proto"
)

// 定义空接口
type TicketService struct {
	__.UnimplementedTicketServiceServer
}

// 实现方法
func (s *TicketService) TicketInfo(ctx context.Context, req *__.TicketInfoRequest) (resp *__.TicketInfoResponse, err error) {
	var ticket dao.Ticket
	config.DB.Where("ticket_name=?", req.TicketName).Limit(1).Find(&ticket)
	if ticket.ID == 0 {
		zap.S().Error("没有该票")
		return
	}
	//sprintf := fmt.Sprintf("%s", ticket.CreatedAt)
	//s2 := fmt.Sprintf("%s", ticket.DeletedAt)
	//if sprintf != req.Start && s2 != req.End {
	//	zap.S().Error("该电影已结束")
	//	return
	//}
	return &__.TicketInfoResponse{
		TicketName:  ticket.TicketName,
		TicketNum:   int64(ticket.TicketNum),
		TicketIntro: ticket.TicketIntro,
	}, nil
}
